namespace GeoBox.Database.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddLastLocationToDevice : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.Device", "LastLocation_DeviceId", c => c.Int());
            AddColumn("dbo.Device", "LastLocation_UtcTime", c => c.DateTime());
            AddColumn("dbo.GpsPoint", "Device_Id", c => c.Int());
            AddForeignKey("dbo.Device", new[] { "LastLocation_DeviceId", "LastLocation_UtcTime" }, "dbo.GpsPoint", new[] { "DeviceId", "UtcTime" });
            AddForeignKey("dbo.GpsPoint", "Device_Id", "dbo.Device", "Id");
            CreateIndex("dbo.Device", new[] { "LastLocation_DeviceId", "LastLocation_UtcTime" });
            CreateIndex("dbo.GpsPoint", "Device_Id");
            DropColumn("dbo.Device", "UtcLastContact");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Device", "UtcLastContact", c => c.DateTime(nullable: false));
            DropIndex("dbo.GpsPoint", new[] { "Device_Id" });
            DropIndex("dbo.Device", new[] { "LastLocation_DeviceId", "LastLocation_UtcTime" });
            DropForeignKey("dbo.GpsPoint", "Device_Id", "dbo.Device");
            DropForeignKey("dbo.Device", new[] { "LastLocation_DeviceId", "LastLocation_UtcTime" }, "dbo.GpsPoint");
            DropColumn("dbo.GpsPoint", "Device_Id");
            DropColumn("dbo.Device", "LastLocation_UtcTime");
            DropColumn("dbo.Device", "LastLocation_DeviceId");
        }
    }
}
